<template>
	<view class="wx-createGroup" :style="'height: calc(100vh - ' + windowTop + 'px)'">
		<watermark></watermark>
		<tool-list-wx :list="list3" @itemClick="goQunliao"></tool-list-wx>
		<view class="wx-createGroup-check"><uni-indexed-list-wx showSelect :showAdd="false" :options="list" @click="bindClick"></uni-indexed-list-wx></view>
		<view style="height: 60px;"></view>
		<view class="wx-createGroup-foot">
			<view class="wx-btn" @click="sendMsg">
				完成
				<text v-if="select.length > 0">({{ select.length }})</text>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			list: [],
			select: [],
			windowTop: 0,
			data: ''
		};
	},
	onLoad(e) {
		this.data = JSON.parse(e.data);
	},
	mounted() {
		this.getfirend();
		uni.getSystemInfo({
			success: res => {
				this.windowTop = res.windowTop;
			}
		});
	},
	computed: {
		list3() {
			return [
				{
					title: '选择群聊',
					path: '#'
				}
			];
		}
	},
	methods: {
		getfirend() {
			this.$http.request({
				url: '/friend/friendList',
				method: 'POST',
				data:JSON.stringify({}),
				success: (res) => {
					if (res.data.code == 200) {
						var data = res.data.data.data
						var list = []
						for (var i = 0; i < data.length; i++) {
							var item=data[i]
							list.push({
								name: item.nickname,
								avatar: item.portrait,
								userId: item.fid,
								userType: item.userType,
								chatNo: item.chatNo
							})
						}
						this.list = this.$fc.sortList({list:list,key:'name'})
					}
				}
			});
		},
		sendMsg() {
			if(this.select.length <= 0){
				uni.showToast({
					title: '未选择',
					icon: 'none'
				})
				return
			}
			for (var i = 0; i < this.select.length; i++) {
				var userId = this.select[i].data.userId;
				this.$fc.pushOutMsg({
					msgContent: this.data.content,
					msgType: this.data.msgType,
					windowType: 'SINGLE',
					userId: userId
				});
			}
			uni.$emit('manyMsgSendSuccess',{msg:'多条消息转发成功'});
			this.$fc.ToastBack('已转发',2);
		},
		bindClick(e) {
			this.select = e.select;
		},
		goQunliao(){
			uni.navigateTo({
				url: this.$fc.get_package_name()+'message_zhuanfa/qunliao?data=' + JSON.stringify(this.data)
			})
		}
	}
};
</script>

<style scoped>
.top_text{
	padding: 30rpx 20rpx;
	font-size: 28rpx;
}
.top_text text.lr{
	font-weight: 600;
}
.top_text text.rr{
	color: steelblue;
	float: right;
	font-weight: 600;
}
.wx-createGroup {
	display: flex;
	flex-direction: column;
}
.wx-createGroup-check {
	height: 90%;
	position: relative;
}
.wx-createGroup-foot {
	width: 100%;
	height: 60px;
	line-height: 60px;
	background-color: #eee;
	position: fixed;
	bottom: 0;
	left: 0;
	text-align: right;
}
.wx-btn {
	height: 40px;
	line-height: 40px;
	min-width: 200rpx;
	text-align: center;
	border-radius: 12rpx;
	background-color: #05c160;
	color: #fff;
	font-size: 32rpx;
	display: inline-block;
	margin-top: 10px;
	margin-right: 20rpx;
}
</style>
